function [] = buildGraphs (CON, tactNumber, tactsInDay)
global connectorPath
global host
global port
global dbname
global user
global password

javaaddpath(CON.connectorPath); 
driver = 'com.mysql.jdbc.Driver';
url = ['jdbc:mysql://' CON.host ':' num2str(CON.port) '/' CON.dbname];
conn = database(CON.dbname, CON.user, CON.password, driver, url);

if isconnection(conn)
	day = cell2mat(get(fetch(exec(conn, 'select CurrentDay from ManufacturingInit;')),'Data'))
	daytacts = cell2mat(get(fetch(exec(conn, 'select TactsInWorkingDay from ManufacturingInit;')),'Data'));
		
	%Graph building interval (for DoneProduct and WorkTimeForChange)
	graphInterval = 10;
	%IF Current day is the day to build graphs and current tact is the last tact of current day
	%if ( (abs( (day / graphInterval) - fix(day / graphInterval) ) == 0) && ( (tactNumber/daytacts) == day) )
	if ( (abs( ( (day+1) / graphInterval) - fix( (day+1) / graphInterval) ) == 0) && ( (tactNumber/tactsInDay) == day) )
		graphData = cell2mat(get(fetch(exec(conn,strcat('select Day, WorkTimeForChange, DoneProduct from ManufacturingLog where Day in (', int2str(day - graphInterval),',', int2str(day),') ORDER BY Day;'))),'Data'));
		%DoneProduct
		DoneProductGraph = figure('Name', 'Done Product by Days');
		plot( graphData(:,1) , graphData(:,3));
		saveas(DoneProductGraph,strcat('DoneProduct_',day),'png');
		%WorkTimeForChange
		WorkTimeForChangeGraph = figure('Name', 'WorkTime for Line Change by Days');
		plot( graphData(:,1) , graphData(:,2));
		saveas(WorkTimeForChangeGraph,strcat('WorkTimeForChange_',day),'png');
	end %if (abs((day / graphInterval)-fix(day / graphInterval)) == 0)	
end
end